<template>
  <div class="workflow-form">
    <a-form
      :model="form"
      name="form"
      label-wrap
      :label-col="{ span: 24 }"
      :wrapper-col="{ span: 24 }"
      autocomplete="off"
    >
      <a-form-item
        label="流程名称"
        name="flowName"
        :rules="[{ required: true, message: '请输入流程名称', trigger: 'blur' }]"
      >
        <a-input v-model:value="form.flowName" placeholder="流程名称"></a-input>
      </a-form-item>
      <a-form-item
        label="流程类型"
        name="flowType"
        :rules="[{ required: true, message: '请选择流程类型', trigger: 'change' }]"
      >
        <DictFormItem
          v-model:value="form.flowType"
          v-model:name="form.flowTypeName"
          placeholder="请选择"
          app-code="CTMS"
          flag="PROCESS_TYPE"
          :is-http="true"
          :disabled="isDisabledFlowType"
        />
      </a-form-item>
      <a-form-item label="试验类型" name="testType">
        <DictFormItem
          v-model:value="form.testType"
          app-code="CONFIG"
          flag="PROJECT_TYPE"
          placeholder="试验类型"
          :is-http="true"
        />
      </a-form-item>
      <a-form-item label="流程版本" name="flowVersion">
        <a-input v-model:value="form.flowVersion" placeholder="请输入"></a-input>
      </a-form-item>
      <a-form-item label="流程描述" name="flowDesc">
        <a-input v-model:value="form.flowDesc" placeholder="请输入"></a-input>
      </a-form-item>
      <a-form-item v-if="route.query.id || isModal" label="创建人" name="createUserName">
        <a-input v-model:value="form.createUserName" disabled placeholder="创建人"></a-input>
      </a-form-item>
      <a-form-item v-if="route.query.id || isModal" label="创建时间" name="createTime">
        <a-input v-model:value="form.createTime" disabled placeholder="创建时间"></a-input>
      </a-form-item>
      <a-form-item v-if="route.query.id || isModal" label="最后编辑人" name="lastEditUserName">
        <a-input v-model:value="form.lastEditUserName" disabled placeholder="最后编辑人"></a-input>
      </a-form-item>
      <a-form-item v-if="route.query.id || isModal" label="最后编辑时间" name="lastEditTime">
        <a-input v-model:value="form.lastEditTime" disabled placeholder="最后编辑时间"></a-input>
      </a-form-item>
    </a-form>
  </div>
</template>
<script lang="ts" setup name="WorkflowForm">
import { reactive, onBeforeUnmount } from 'vue'
import { useRoute } from 'vue-router'
const emit = defineEmits(['close'])
const props = defineProps({
  currentNode: {
    type: Object,
    default: () => {}
  },
  isModal: {
    type: Boolean,
    default: false
  },
  isDisabledFlowType: {
    type: Boolean,
    default: false
  }
})
// console.log(props.currentNode.data.id)
const route = useRoute()
const id = props.currentNode.data.id
const form = reactive(props.currentNode.data.properties)
// form.id = id
form.entryType = 1
form.flowType = form.flowType ? form.flowType + '' : undefined
form.testType = form.testType ? form.testType + '' : undefined

onBeforeUnmount(() => {
  emit('close', form, id)
})
const close = () => {
  emit('close', form, id)
}

defineExpose({
  close
})
// console.log(id)
</script>
<style lang="less">
.workflow-form {
  width: 350px;
}
</style>
